home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / emac16ds.zip / EMACS.ASM < prev    next >
Assembly Source File  |  1992-08-01  |  45KB  |  2,247 lines

  1. ;History:2106,1
  2. ;Thu Mar 26 21:48:00 1992 leave subdirectory names returned by #(ff) in upper case.
  3. ;Sun May 12 00:25:44 1991 Add the new variable "sd", Swap Directory.
  4. ;Sun May 05 19:42:59 1991 add #(hk,...)
  5. ;Sat May 04 22:29:39 1991 added #(!=)
  6. ;Wed May 01 23:36:53 1991 Add #(gl,string) -- Gets a string with no argm interpretation.
  7. ;Sun May 13 23:27:01 1990 add the ability to turn the scroll bar on and off.
  8. ;Mon Apr 16 22:53:55 1990 #(ff) should also find hidden files.
  9. ;Sun Apr 15 00:07:28 1990 #(lv,wp) didn't work right.
  10. ;Mon Mar 05 12:11:46 1990 Remove #(lk) and #(lr)
  11. ;Thu Feb 22 23:39:34 1990 make buffer-modified be a bitmap.
  12. ;Thu Feb 22 23:33:37 1990 add logical operators: || (or), && (and), ^^ (xor).
  13. ;Wed Feb 21 12:42:50 1990 auto_save should only be called on "real" input.
  14. ;Sat Oct 14 23:44:54 1989 in #(ex), if the stdout and stderr names are equal,redirect them to the same handle.
  15. ;Tue Sep 19 23:03:53 1989 Add support for Desqview.
  16. ;Sat Aug 19 23:25:22 1989 add ec_prim -- execution counts.
  17. ;Wed May 03 22:12:32 1989 Use a variable for the default bell pitch.
  18. ;Wed May 03 21:10:16 1989 don't 'and' the background color with 7.
  19. ;Tue Mar 07 23:58:36 1989 add parameters to #(bl)
  20. ;Tue Mar 07 23:33:36 1989 background colors are only three bits -- and them with 7.
  21. ;Mon Jan 30 22:49:56 1989 Add support for multiple colors.
  22. ;10-02-88 20:50:38 add a buffer for mouse clicks.
  23. ;10-01-88 14:50:07 make #(lv,ms) return four numbers.
  24. ;09-23-88 20:37:28 clean up auto_save
  25. ;09-18-88 23:13:35 Add "string index", si_prim
  26. ;09-18-88 12:32:52 use lowercase pathnames in #(lv,cd).
  27. ;09-12-88 23:40:00 if the buffer-modified flag is 2, then the buffer is read-only.
  28. ;09-10-88 05:44:35 Use bl instead of num_screen_cols in announce().
  29. ;09-10-88 05:40:21 try returning / when they try to find it.
  30. ;08-16-88 00:23:20 change auto save so it only count changes to a file.
  31. ;07-24-88 23:25:20 Put the third argument to #(an) *after* the cursor.
  32. ;07-19-88 00:17:27 Create 'li' primitive.
  33. ;05-15-88 19:58:02 Remove reference to non-existent init_memory [kdb]
  34. ;05-07-88 22:07:45 if stdout and stderr are redirected, don't bother swapping screens.
  35. ;04-17-88 22:47:53 add the ex redirect code.
  36. ;04-03-88 23:28:39 move the version number into another file.
  37. ;04-01-88 22:47:59 add tc variable.
  38. ;03-30-88 21:22:49 move xlat_to_mark to memory.asm
  39. ;03-30-88 20:48:45 add tr_prim
  40. ;03-27-88 19:47:54 add store_firstline and store_lastline
  41. ;03-26-88 15:53:35 put the variables in alphabetic order.
  42. ;03-26-88 14:24:12 expand the ?v_prim symbols to the two letter symbols.
  43. ;03-26-88 10:02:03 get rid of old single-letter variables.
  44. ;03-26-88 10:01:52 add auto-save counter
  45. ;03-23-88 23:56:09 Add variables 'fo' and 'bo' for original colors.
  46. ;03-13-88 12:27:10 remove #(ef)
  47. ;03-10-88 22:41:26 add #(l?)
  48. ;12-13-87 21:17:22 
  49. ;11-26-87 11:45:11 fix goofyness in it_prim.
  50. ;09-09-87 00:49:51 after fixing redisp for the column redisplay bug, bump the version.
  51. ;07-15-87 22:10:51 up the version letter because I gave a copy to Pat.
  52. ;07-13-87 23:11:23 remove xyputch.
  53. ;07-13-87 23:00:03 move things around between files.
  54. ;07-10-87 23:09:06 add #(lv,vn) - version number.
  55. ;07-10-87 22:54:07 fix the problem with #(lv,xx) where xx is not a variable.
  56. ;07-10-87 00:23:10 remove trailing blank from #(sv,cd,...)
  57. ;07-10-87 00:17:28 add #(sv,cd,...)
  58. ;07-08-87 21:37:15 put a trailing \ on 'cd' variable.
  59. ;07-08-87 21:01:05 create the 'cd' variable.
  60. ;07-05-87 14:16:38 make complete paths in ff_prim an assembly-time option.
  61. ;07-05-87 14:02:28 compute the prefix length in ff_prim properly.
  62. ;07-05-87 11:55:54 Return full pathname and lowercase in ff_prim.
  63. test_prims    equ    0
  64.     page    ,132
  65.  
  66.     .xlist
  67.     include    emacs.def
  68.     include    memory.def
  69.     include    mint.def
  70.     include    findfile.def
  71.  
  72. data    segment    byte public
  73.  
  74.     extrn    version_number: byte, version_number_len: abs
  75.  
  76. ;the following externs are defined in 'mintprim'
  77.     extrn    read_errors: word
  78.     extrn    write_errors: word
  79.     extrn    data_bottop: word
  80.     extrn    data_topbot: word
  81.  
  82. ;the following externs are defined in 'mintscan'
  83.     extrn    fbgn: word, fend: word
  84.     extrn    next_ids: word
  85.  
  86. ;the following externs are defined in the computer-dependent file.
  87.     extrn    max_screen_line: byte
  88.     extrn    num_screen_cols: word
  89.     extrn    computer_name: byte
  90.     extrn    computer_name_len: abs
  91.  
  92.     public    filename, filename2
  93. filename    db    64 dup(?)
  94. filename2    db    64 dup(?)
  95.  
  96. rename_error    db    'Rename error'
  97. rename_error_len    equ    $-rename_error
  98.  
  99. speller_txt    db    'Speller'
  100. speller_txt_len    equ    $-speller_txt
  101.  
  102.     extrn    next_redisp_line: word
  103.  
  104.     public    standard_ids
  105. standard_ids    db    '#(d,#(g))',0
  106.  
  107. nokbd_ids    db    '#(k)#(d,#(g))',0
  108. auto_ids    db    '#(Fauto-save)',0
  109.  
  110. auto_save_limit    dw    0
  111. auto_save_cntr    dw    0
  112.  
  113. byte_ptr    label    byte
  114.  
  115. color_list    label    byte
  116. fore_color    db    7
  117. back_color    db    0
  118. control_color    db    2
  119. whitespc_color    db    7
  120.  
  121. bell_pitch    dw    2000
  122.  
  123. ex_stdin    dw    ?        ;-1 if we're not redirecting.
  124. ex_stdout    dw    ?        ;-1 if we're not redirecting.
  125. ex_stderr    dw    ?        ;-1 if we're not redirecting.
  126.     extrn    swap_screen_flag: word    ;=1 if we should swap screens.
  127.  
  128.     extrn    tab_size: word
  129.     extrn    fore_original: byte
  130.     extrn    back_original: byte
  131.  
  132. variable_table    label    byte
  133.     db    'as'            ;Auto Save
  134.     db    'bc'            ;Background Color
  135.     db    'bl'            ;Bot Line
  136.     db    'bo'            ;Background Original
  137.     db    'bs'            ;Bot Scroll
  138.     db    'cc'            ;Control Color
  139.     db    'cd'            ;Current Directory
  140.     db    'cl'            ;Line Number
  141.     db    'cn'            ;Computer Name
  142.     db    'cs'            ;Column on Screen
  143.     db    'cw'            ;Current Window
  144.     db    'bp'            ;Bell Pitch
  145.     db    'fc'            ;Foreground Color
  146.     db    'fo'            ;Foreground Original
  147.     db    'im'            ;Inverse Mark
  148.     db    'is'            ;Inhibit Snow
  149.     db    'lc'            ;Lefthand Column
  150.     db    'mb'            ;Modified Buffer
  151.     db    'ms'            ;Mint Space
  152.     db    'nl'            ;Number of Lines
  153.     db    'ow'            ;Other Window
  154.     db    'pb'            ;Percent of Buffer
  155.     db    'rc'            ;Rightmost Column
  156.     db    'rs'            ;Row on Screen
  157.     db    'sb'            ;Scroll Bar
  158.     db    'tc'            ;Tab Columns
  159.     db    'tl'            ;Top Line
  160.     db    'ts'            ;Top Scroll
  161.     db    'vn'            ;Version Number
  162.     db    'wc'            ;Whitespace Color
  163.     db    'ws'            ;Whitespace Showing
  164. variable_count    equ    ($-variable_table)/2
  165.  
  166. lv_prim_table    label    word
  167.     dw    lv_prim_as
  168.     dw    lv_prim_bc
  169.     dw    lv_prim_bl
  170.     dw    lv_prim_bo
  171.     dw    lv_prim_bs
  172.     dw    lv_prim_cc
  173.     dw    lv_prim_cd
  174.     dw    lv_prim_cl
  175.     dw    lv_prim_cn
  176.     dw    lv_prim_cs
  177.     dw    lv_prim_cw
  178.     dw    lv_prim_bp
  179.     dw    lv_prim_fc
  180.     dw    lv_prim_fo
  181.     dw    lv_prim_im
  182.     dw    lv_prim_is
  183.     dw    lv_prim_lc
  184.     dw    lv_prim_mb
  185.     dw    lv_prim_ms
  186.     dw    lv_prim_nl
  187.     dw    lv_prim_ow
  188.     dw    lv_prim_pb
  189.     dw    lv_prim_rc
  190.     dw    lv_prim_rs
  191.     dw    lv_prim_sb
  192.     dw    lv_prim_tc
  193.     dw    lv_prim_tl
  194.     dw    lv_prim_ts
  195.     dw    lv_prim_vn
  196.     dw    lv_prim_wc
  197.     dw    lv_prim_ws
  198.  
  199. sv_prim_table    label    word
  200.     dw    sv_prim_as
  201.     dw    sv_prim_bc
  202.     dw    sv_prim_bl
  203.     dw    sv_prim_bo
  204.     dw    sv_prim_bs
  205.     dw    sv_prim_cc
  206.     dw    sv_prim_cd
  207.     dw    sv_prim_cl
  208.     dw    sv_prim_cn
  209.     dw    sv_prim_cs
  210.     dw    sv_prim_cw
  211.     dw    sv_prim_bp
  212.     dw    sv_prim_fc
  213.     dw    sv_prim_fo
  214.     dw    sv_prim_im
  215.     dw    sv_prim_is
  216.     dw    sv_prim_lc
  217.     dw    sv_prim_mb
  218.     dw    sv_prim_ms
  219.     dw    sv_prim_nl
  220.     dw    sv_prim_ow
  221.     dw    sv_prim_pb
  222.     dw    sv_prim_rc
  223.     dw    sv_prim_rs
  224.     dw    sv_prim_sb
  225.     dw    sv_prim_tc
  226.     dw    sv_prim_tl
  227.     dw    sv_prim_ts
  228.     dw    sv_prim_vn
  229.     dw    sv_prim_wc
  230.     dw    sv_prim_ws
  231.  
  232.     extrn    stackp: byte
  233.  
  234.     public    trace_handle
  235. trace_handle    dw    -1
  236.  
  237. sa_jump        dw    ?
  238. sa_n_jump    dw    ?
  239.  
  240. mouse_buffer    dw    0        ;mouse button buffer.
  241.  
  242.   if timing
  243.     public    counting
  244. counting    db    0
  245.     extrn    counts: word
  246.     extrn    times: word
  247.   endif
  248.  
  249.     extrn    swapfname: byte
  250.  
  251. data    ends
  252.  
  253.  
  254. code    segment    byte public
  255.     assume    cs:code, ds:data, es:data
  256.  
  257.     extrn    set_screen_color: near
  258.  
  259.     extrn    redisplay: near        ;ax=line to leave the cursor on.
  260.  
  261.     extrn    buffer_free: near
  262.     extrn    read_firstline: near
  263.     extrn    read_lastline: near
  264.     extrn    store_firstline: near
  265.     extrn    store_lastline: near
  266.     extrn    read_newrow: near
  267.     extrn    read_linesbefore: near
  268.     extrn    read_linecount: near
  269.     extrn    read_buffer_modified: near
  270.     extrn    store_buffer_modified: near
  271.     extrn    read_ibm_cga: near
  272.     extrn    store_ibm_cga: near
  273.     extrn    read_scroll_bar: near
  274.     extrn    store_scroll_bar: near
  275.     extrn    read_inverse_mark: near
  276.     extrn    store_inverse_mark: near
  277.  
  278.     extrn    read_showblanks: near
  279.     extrn    store_showblanks: near
  280.  
  281.     extrn    read_top_percent: near
  282.     extrn    read_bot_percent: near
  283.     extrn    store_top_percent: near
  284.     extrn    store_bot_percent: near
  285.  
  286.     extrn    read_other_window: near
  287.     extrn    read_current_window: near
  288.     extrn    store_other_window: near
  289.     extrn    store_current_window: near
  290.  
  291.     extrn    chrout: near        ;al=char to overwrite to screen.
  292.  
  293.     extrn    paint_screen: near    ;sets entire screen to be repainted.
  294.  
  295.     extrn    paint_window: near    ;causes the current buffer to be shown in the current window.
  296.  
  297.     extrn    insert_string: near    ;si,cx describe the string.
  298.  
  299.     extrn    buffer_allocate: near    ;entry: cx=buffer number to select,
  300.                     ;  cx=0 to create new buffer.
  301.                     ;  ax=0 for read/write buffer.
  302.                     ;exit: ax=new buffer number if enough
  303.                     ;  memory, ax=0 otherwise.
  304.     extrn    read_mark: near        ;entry: al=mark to read to.
  305.                     ;exit: es:si, cx describing string.
  306.  
  307.     extrn    del_to_mark: near    ;entry: al=mark to delete to.
  308.  
  309.     extrn    set_mark: near        ;entry: al=dest mark, ah=source mark.
  310.  
  311.     extrn    goto_mark: near        ;entry: al=mark to go to.
  312.  
  313.     extrn    xlat_to_mark: near    ;entry: al=mark to translate to.
  314.                     ;  es:bx = translate table,
  315.                     ;  dx = length of translate table.
  316.  
  317.     extrn    stack_marks: near    ;entry: ax>0 to create temp marks,
  318.                     ;  ax=0 to delete temp marks,
  319.                     ;  ax<0 to create perm marks and delete
  320.                     ;  all temp marks.
  321.  
  322.     extrn    compute_cursor: near    ;exit with dx=column (0..65535)
  323.  
  324.     extrn    set_column: near    ;entry: ax=desired column
  325.  
  326.     extrn    set_line: near        ;entry: ax=desired line.
  327.  
  328.     extrn    read_firstcolumn: near    ;get the left hand column.
  329.  
  330.     extrn    store_firstcolumn: near    ;set the left hand column.
  331.  
  332.     extrn    ring_the_bell: near
  333.  
  334.  
  335. ;the following extrns are in the computer-dependent file
  336.     extrn    xychrout: near
  337.     extrn    clear_count: near
  338.     extrn    position_cursor: near
  339.     extrn    check_for_key: near
  340.     extrn    give_up_slice: near
  341.  
  342. ;the following extrns are in 'files'
  343.     extrn    read_file: near
  344.     extrn    write_file: near
  345.  
  346. ;the following extrns are in 'search'
  347.     extrn    regexp_pat: near
  348.     extrn    set_pattern: near
  349.     extrn    search: near
  350.  
  351. ;the following extrns are in 'mintscan'
  352.     extrn    nomem: near
  353.  
  354. ;the following externs are in 'pick'
  355.     extrn    pick_on: near
  356.     extrn    pick_off: near
  357.     extrn    check_pick: near
  358.     extrn    get_pick_values: near
  359.  
  360.  
  361.     public    init_ids
  362. init_ids:
  363.     mov    sp,offset stackp
  364.     call    check_for_key        ;use the standard ids only if kbd ready.
  365.     jnz    init_ids_1
  366.     mov    ax,offset nokbd_ids
  367. init_ids_2:
  368.     cmp    next_ids,offset standard_ids    ;only use a different one if
  369.     jne    init_ids_1            ;we're at the standard ids.
  370.     mov    next_ids,ax
  371. init_ids_1:
  372.     jmp    init_ids_continue
  373.  
  374.     extrn    init_ids_continue: near
  375.  
  376.  
  377. write_protect:
  378.     call    read_buffer_modified    ;see if this buffer is read-only.
  379.     test    al,2
  380.     jne    write_protect_1        ;yes - leave immediately.
  381.     ret
  382. write_protect_1:
  383.     pop    ax            ;discard our return address.
  384.     jmp    return_null
  385.  
  386.  
  387. auto_save:
  388. ;preserve bp.
  389.     mov    ax,auto_save_cntr    ;is the counter already at zero?
  390.     or    ax,ax            ;is the counter already at zero?
  391.     je    auto_save_1        ;yes - don't decrement it.
  392.     dec    ax            ;time to auto-save?
  393.     jne    auto_save_1        ;no.
  394.     mov    ax,auto_save_limit    ;yes - reset the counter.
  395.     mov    next_ids,offset auto_ids
  396. auto_save_1:
  397.     mov    auto_save_cntr,ax
  398.     ret
  399.  
  400.  
  401.     if    test_prims
  402.  
  403. ;test primitive.  fills memory to the max.  strictly for testing only.
  404. ts_prim:
  405.     di_points_fbgn
  406.     mov    cx,data_topbot
  407.     sub    cx,di
  408.     dec    cx
  409.     push    cx
  410.     mov    al,' '
  411.     rep    stosb
  412.     pop    cx
  413.     jmp    return_sicx
  414.  
  415.  
  416. formSeg    segment    public
  417. ;the following externs are defined in 'mintform'
  418.     extrn    formhash: word
  419. formSeg    ends
  420.  
  421. ;dump formhash.  strictly for testing only.
  422. tt_prim:
  423.     mov    cx,256
  424.     di_points_fbgn
  425.     chk_room_cnt
  426.     mov    si,offset formhash
  427. tt_prim_1:
  428.     test    cx,3fh
  429.     jne    tt_prim_4
  430.     mov    ax,LINENEW
  431.     stosw
  432. tt_prim_4:
  433.     mov    dx,0
  434.     lodsw
  435.     mov    bx,ax
  436. tt_prim_2:
  437.     cmp    bx,NIL        ;at end of list yet?
  438.     je    tt_prim_3
  439.     mov    bx,[bx].hash_link
  440.     inc    dx
  441.     jmp    tt_prim_2
  442. tt_prim_3:
  443.     mov    ax,dx        ;get the count
  444.     add    al,'0'        ;convert to ascii (cheaply)
  445.     stosb
  446.     loop    tt_prim_1
  447.     jmp    return_tos
  448.  
  449.     endif
  450.  
  451.   if timing
  452. ec_prim:
  453.     call    getarg1
  454.     jcxz    ec_prim_0
  455.  
  456. ;zero out the old times.
  457.     xor    bx,bx
  458.     mov    cx,function_name_length
  459. ec_prim_8:
  460.     mov    counts[bx],0
  461.     mov    times[bx],0
  462.     add    bx,2
  463.     loop    ec_prim_8
  464.  
  465. ;now say that we're counting, and init the timer chip.
  466.     mov    counting,1
  467.     mov    al,34h
  468.     out    43h,al
  469.     jmp    short ec_prim_3
  470. ec_prim_3:
  471.     mov    al,0
  472.     out    40h,al
  473.     jmp    short ec_prim_4
  474. ec_prim_4:
  475.     mov    al,0
  476.     out    40h,al
  477.     jmp    return_null
  478.  
  479. ec_prim_0:
  480.     xor    bx,bx
  481.     mov    si,offset function_name_table
  482.     di_points_fbgn
  483.     mov    cx,function_name_length * (2 + 1 + 5 + 2)
  484.     chk_room_cnt
  485.     mov    cx,function_name_length
  486. ec_prim_1:
  487.     movsw
  488.     mov    al,' '
  489.     stosb
  490.  
  491.     push    bx
  492.     push    cx
  493.  
  494.     push    times[bx]
  495.  
  496.     mov    ax,counts[bx]
  497.     mov    cx,5            ;always use 5 digits.
  498.     mov    bx,10
  499.     call    put_number
  500.  
  501.     pop    ax
  502.  
  503.     cmp    counting,0        ;are we counting?
  504.     je    ec_prim_7
  505.  
  506.     mov    byte ptr [di],' '
  507.     inc    di
  508.  
  509.     mov    cx,5            ;always use 5 digits.
  510.     mov    bx,10
  511.     call    put_number
  512.  
  513. ec_prim_7:
  514.     pop    cx
  515.     pop    bx
  516.  
  517.     mov    times[bx],0        ;zero the counters.
  518.     mov    counts[bx],0
  519.  
  520.     mov    al,CR
  521.     stosb
  522.     mov    al,LF
  523.     stosb
  524.     add    bx,2
  525.     loop    ec_prim_1
  526.  
  527.     cmp    counting,0        ;restore the counter only if we were
  528.     je    ec_prim_2        ;  counting.
  529.  
  530.     mov    al,36h
  531.     out    43h,al
  532.     jmp    short ec_prim_5
  533. ec_prim_5:
  534.     mov    al,0
  535.     out    40h,al
  536.     jmp    short ec_prim_6
  537. ec_prim_6:
  538.     mov    al,0
  539.     out    40h,al
  540.  
  541. ec_prim_2:
  542.     mov    counting,0
  543.     jmp    return_tos
  544.   endif
  545.  
  546.  
  547. ;redisplay.
  548. rd_prim:
  549.     call    getarg1
  550.     jcxz    rd_prim_1
  551.     call    paint_screen        ;paint,
  552.     call    paint_window
  553.     jmp    short rd_prim_3        ; always redisplay
  554. rd_prim_1:
  555.     call    check_for_key        ;redisplay only if no key waiting.
  556.     jnz    rd_prim_2
  557. rd_prim_3:
  558.     call    redisplay
  559. rd_prim_2:
  560.     jmp    return_null
  561.  
  562.  
  563. ;overwrite the screen.
  564. ow_prim:
  565.     call    getarg1
  566.     jcxz    ow_prim_2
  567. ow_prim_1:
  568.     lodsb
  569.     xor    ah,ah
  570.     call    chrout
  571.     push    si
  572.     push    cx
  573.     pop    cx
  574.     pop    si
  575.     loop    ow_prim_1
  576. ow_prim_2:
  577.     jmp    return_null
  578.  
  579.  
  580.     extrn    get_math: near
  581.     extrn    gotoxy: near
  582.  
  583. ;gotoxy
  584. xy_prim:
  585.     call    get_math
  586.     mov    dh,al
  587.     mov    dl,bl
  588.     call    gotoxy
  589.     jmp    return_null
  590.  
  591.  
  592. ;announce a string
  593. an_prim:
  594.     mov    bx,num_screen_cols    ;end of the line.
  595.     mov    cx,2            ;if the second arg is non-null,
  596.     mov    dh,0            ;start in this column
  597.     call    getarg
  598.     jcxz    an_prim_1
  599.     call    read_lastline        ;  put the announcement after the current window.
  600.     inc    al
  601.     mov    dl,al
  602.     call    announce1
  603.     call    clear_count        ;clear to the end of the annunciator.
  604.     jmp    return_null
  605. an_prim_1:
  606.     mov    dl,max_screen_line    ;get the row.
  607.     inc    dl
  608.     inc    dl            ;put our announcement after it.
  609.     call    announce1        ;announce the left part.
  610.     call    position_cursor        ;  put the cursor at the end of the string
  611.     mov    cx,3            ;now announce the right part.
  612.     call    announce
  613.     call    clear_count        ;clear to the end of the annunciator.
  614.     jmp    return_null
  615.  
  616.  
  617. announce1:
  618.     mov    cx,1
  619. announce:
  620. ;given an argument in cx, print it at row=dl, column=dh.
  621.     call    getarg
  622.     jcxz    announce_2        ;if null, we';re done.
  623. announce_1:
  624.     cmp    dh,bl            ;end of the line.
  625.     jae    announce_2        ;if we hit end of line, we're done.
  626.     lodsb                ;get a character.
  627.     mov    ah,0
  628.     call    xychrout
  629.     inc    dh
  630.     loop    announce_1
  631. announce_2:
  632.     ret
  633.  
  634.  
  635. ;insert a string.
  636. is_prim:
  637.     call    write_protect
  638.     call    getarg1
  639.     call    insert_string
  640.     jc    is_prim_1        ;go if we can't insert it.
  641.     jmp    return_null
  642. is_prim_1:
  643.     mov    cx,2
  644.     jmp    return_arg
  645.  
  646.  
  647.     extrn    get_mint_space: near
  648.  
  649. lv_prim:
  650. ;load variable
  651.     mov    bx,offset lv_prim_table
  652.     call    parse_variable
  653.     di_points_fbgn
  654.     jmp    word ptr [bx]
  655.  
  656. lv_prim_cd:
  657.     mov    cx,64+3            ;we need at most 64 plus 'a:\'.
  658.     chk_room_cnt
  659.     mov    ah,19h            ;get the current drive.
  660.     int    21h
  661.     mov    dl,al
  662.     inc    dl
  663.     add    al,'a'
  664.     stosb
  665.     mov    ax,':' + '\'*256
  666.     stosw
  667.  
  668.     mov    si,di            ;get the directory here.
  669.     mov    ah,47h            ;get current directory.
  670.     int    21h
  671. lv_prim_cd_1:                ;find the terminating null.
  672.     lodsb
  673.     call    to_lower        ;lowercase the filename.
  674.     mov    [si-1],al
  675.     or    al,al
  676.     jne    lv_prim_cd_1
  677.     dec    si
  678.     xchg    di,si            ;di should point to the null.
  679.  
  680.     cmp    si,di            ;are we in a subdirectory?
  681.     je    lv_prim_cd_2
  682.     mov    al,'\'            ;yes - store a trailing backslash.
  683.     stosb
  684. lv_prim_cd_2:
  685.     jmp    return_tos
  686.  
  687.  
  688. lv_prim_vn:
  689.     mov    si,offset version_number
  690.     mov    cx,version_number_len
  691.     chk_room_cnt
  692.     rep    movsb
  693.     jmp    return_tos
  694.  
  695.  
  696. lv_prim_cn:
  697.     mov    si,offset computer_name
  698.     mov    cx,computer_name_len
  699.     chk_room_cnt
  700.     rep    movsb
  701.     jmp    return_tos
  702.  
  703.  
  704. lv_prim_im:
  705.     call    read_inverse_mark
  706.     stosb
  707.     jmp    return_tos
  708.  
  709. lv_prim_pb:
  710.     call    read_linecount
  711.     inc    ax
  712.     push    ax
  713.     call    read_linesbefore
  714.     inc    ax
  715.     mov    dx,100
  716.     mul    dx
  717.     pop    cx
  718.     div    cx
  719.     jmp    return_number
  720.  
  721. lv_prim_ms:
  722.     mov    cx,6*4
  723.     chk_room_cnt
  724.     call    get_mint_space
  725.     jmp    return_tos
  726.  
  727. lv_prim_bp:
  728.     mov    ax,bell_pitch
  729.     jmp    return_number
  730.  
  731. lv_prim_fc:
  732.     mov    ah,0
  733.     mov    al,fore_color
  734.     jmp    return_number
  735.  
  736. lv_prim_bc:
  737.     mov    ah,0
  738.     mov    al,back_color
  739.     jmp    return_number
  740.  
  741. lv_prim_cc:
  742.     mov    ah,0
  743.     mov    al,control_color
  744.     jmp    return_number
  745.  
  746. lv_prim_wc:
  747.     mov    ah,0
  748.     mov    al,whitespc_color
  749.     jmp    return_number
  750.  
  751. lv_prim_fo:
  752.     mov    ah,0
  753.     mov    al,fore_original
  754.     jmp    return_number
  755.  
  756. lv_prim_bo:
  757.     mov    ah,0
  758.     mov    al,back_original
  759.     jmp    return_number
  760.  
  761. lv_prim_ow:
  762.     call    read_other_window
  763.     jmp    return_number
  764.  
  765. lv_prim_cw:
  766.     call    read_current_window
  767.     jmp    return_number
  768.  
  769. lv_prim_ts:
  770.     call    read_top_percent
  771.     mov    ah,0
  772.     jmp    return_number
  773. lv_prim_bs:
  774.     call    read_bot_percent
  775.     mov    ah,0
  776.     jmp    return_number
  777. lv_prim_ws:
  778.     call    read_showblanks
  779.     mov    ah,0
  780.     jmp    return_number
  781. lv_prim_nl:
  782.     call    read_linecount
  783.     inc    ax
  784.     jmp    return_number
  785. lv_prim_rc:
  786.     mov    ax,num_screen_cols
  787.     inc    ax
  788.     jmp    return_number
  789. lv_prim_rs:
  790.     call    read_newrow
  791.     inc    ax
  792.     jmp    return_number
  793. lv_prim_cs:
  794.     call    compute_cursor
  795.     mov    ax,dx
  796.     inc    ax
  797.     jmp    return_number
  798. lv_prim_lc:
  799.     call    read_firstcolumn
  800.     inc    ax
  801.     jmp    return_number
  802. lv_prim_tc:
  803.     mov    ax,tab_size
  804.     inc    ax
  805.     jmp    return_number
  806. lv_prim_sb:
  807.     call    read_scroll_bar
  808.     mov    ah,0
  809.     jmp    return_number
  810. lv_prim_tl:
  811.     call    read_firstline
  812.     mov    ah,0
  813.     inc    ax
  814.     jmp    return_number
  815. lv_prim_bl:
  816.     call    read_lastline
  817.     mov    ah,0
  818.     inc    ax
  819.     jmp    return_number
  820. lv_prim_mb:
  821.     call    read_buffer_modified
  822.     mov    ah,0
  823.     jmp    return_number
  824. lv_prim_is:
  825.     call    read_ibm_cga
  826.     mov    ah,0
  827.     jmp    return_number
  828. lv_prim_as:
  829.     mov    ax,auto_save_limit
  830.     jmp    return_number
  831. lv_prim_cl:
  832.     call    read_linesbefore
  833.     inc    ax
  834.     jmp    return_number
  835.  
  836.  
  837. sv_prim:
  838. ;store variable
  839.     mov    bx,offset sv_prim_table
  840.     call    parse_variable
  841.     push    bx
  842.     mov    cx,2
  843.     call    get_decimal_arg
  844.     pop    bx
  845.     call    word ptr [bx]
  846.     jmp    return_null
  847.  
  848. sv_prim_bp:
  849.     mov    bell_pitch,ax
  850.     ret
  851.  
  852.  
  853. sv_prim_fc:
  854.     mov    fore_color,al
  855.     mov    si,offset color_list
  856.     call    set_screen_color
  857.     ret
  858.  
  859. sv_prim_bc:
  860.     mov    back_color,al
  861.     mov    si,offset color_list
  862.     call    set_screen_color
  863.     ret
  864.  
  865. sv_prim_cc:
  866.     mov    control_color,al
  867.     mov    si,offset color_list
  868.     call    set_screen_color
  869.     ret
  870.  
  871.  
  872. sv_prim_wc:
  873.     mov    whitespc_color,al
  874.     mov    si,offset color_list
  875.     call    set_screen_color
  876.     ret
  877.  
  878.  
  879. sv_prim_ow:
  880.     call    store_other_window
  881.     ret
  882.  
  883. sv_prim_cw:
  884.     call    store_current_window
  885.     ret
  886.  
  887. sv_prim_ts:
  888.     call    store_top_percent
  889.     ret
  890. sv_prim_bs:
  891.     call    store_bot_percent
  892.     ret
  893. sv_prim_ws:
  894.     call    store_showblanks    ;whitespace.
  895.     ret
  896. sv_prim_im:
  897.     mov    cx,2
  898.     call    getarg_mark
  899.     call    store_inverse_mark
  900.     ret
  901. sv_prim_cd:
  902.     mov    cx,2            ;get the "filename" into filename.
  903.     call    getarg_filename
  904.     mov    ax,[si]            ;get the first two chars.
  905.     or    al,al            ;do we have anything at all?
  906.     je    sv_prim_cd_1        ;no.
  907.     cmp    ah,':'            ;is the second char ':'?
  908.     jne    sv_prim_cd_2        ;no.
  909.     add    si,2            ;parse past these characters.
  910.     call    to_lower        ;convert the drive character to lowercase.
  911.     sub    al,'a'
  912.     mov    ah,0eh            ;select drive
  913.     mov    dl,al
  914.     int    21h
  915. sv_prim_cd_2:
  916.     mov    dx,si            ;save a copy and find the first null.
  917. sv_prim_cd_3:
  918.     lodsb
  919.     or    al,al
  920.     jne    sv_prim_cd_3
  921.     sub    si,2            ;make si -> last char of path.
  922.     cmp    si,dx            ;is this a one character subdir?
  923.     je    sv_prim_cd_4        ;yes - don't strip trailing slashes.
  924.     xor    al,al
  925.     xchg    al,[si]            ;store a null there.
  926.     cmp    al,'\'            ;was it a backslash?
  927.     je    sv_prim_cd_4        ;yes.
  928.     cmp    al,'/'            ;was it a slash?
  929.     je    sv_prim_cd_4        ;yes.
  930.     mov    [si],al            ;no - store the original char.
  931. sv_prim_cd_4:
  932.     mov    ah,3bh            ;change to this directory.
  933.     int    21h
  934. sv_prim_cd_1:
  935.     ret
  936.  
  937. sv_prim_tc:
  938.     cmp    ax,2
  939.     je    sv_prim_tc_1
  940.     cmp    ax,4
  941.     je    sv_prim_tc_1
  942.     cmp    ax,8
  943.     je    sv_prim_tc_1
  944.     cmp    ax,16
  945.     jne    sv_prim_tc_2
  946. sv_prim_tc_1:
  947.     dec    ax
  948.     mov    tab_size,ax
  949.     call    paint_screen
  950. sv_prim_tc_2:
  951.     ret
  952.  
  953. sv_prim_sb:
  954.     call    store_scroll_bar
  955.     call    paint_screen
  956.     ret
  957.  
  958. sv_prim_tl:
  959.     dec    ax
  960.     call    store_firstline
  961.     ret
  962.  
  963. sv_prim_bl:
  964.     dec    ax
  965.     call    store_lastline
  966.     ret
  967.  
  968. sv_prim_fo:
  969. sv_prim_bo:
  970. sv_prim_vn:
  971. sv_prim_cn:
  972. sv_prim_pb:
  973. sv_prim_ms:
  974. sv_prim_nl:
  975. sv_prim_rc:
  976.     ret
  977. sv_prim_rs:
  978.     mov    next_redisp_line,ax
  979.     ret
  980. sv_prim_cs:
  981.     call    set_column
  982.     ret
  983. sv_prim_lc:
  984.     dec    ax
  985.     call    store_firstcolumn
  986.     ret
  987. sv_prim_mb:
  988.     call    store_buffer_modified
  989.     ret
  990. sv_prim_is:
  991.     call    store_ibm_cga
  992.     ret
  993. sv_prim_as:
  994.     mov    auto_save_limit,ax
  995.     mov    auto_save_cntr,ax
  996.     ret
  997. sv_prim_cl:
  998.     call    set_line
  999.     ret
  1000.  
  1001.  
  1002.  
  1003.  
  1004. parse_variable:
  1005. ;parse a variable letter.
  1006. ;return bx -> proper entry in the table pointed to by bx on entry.
  1007. ;the default is at the end of the table.
  1008.     call    getarg1
  1009.     mov    ax,'l'            ;defaults to line
  1010.     jcxz    parse_variable_1
  1011.     lodsb
  1012.     dec    cx
  1013.     je    parse_variable_1
  1014.     mov    ah,[si]
  1015. parse_variable_1:
  1016.     mov    di,offset variable_table
  1017.     mov    cx,variable_count
  1018.     repne    scasw
  1019.     sub    cx,variable_count-1
  1020.     neg    cx
  1021.     shl    cx,1
  1022.     add    bx,cx
  1023.     ret
  1024.  
  1025.  
  1026. pp_prim:
  1027.     di_points_fbgn
  1028.     mov    cx,11            ;make sure there's enough room.
  1029.     chk_room_cnt
  1030.     call    get_pick_values
  1031.     push    dx            ;save vertical
  1032.     mov    ax,cx
  1033.     mov    cx,0
  1034.     mov    bx,10
  1035.     call    put_number
  1036.     mov    al,','
  1037.     stosb
  1038.     pop    ax            ;pushed as dx
  1039.     jmp    return_number
  1040.  
  1041.  
  1042. sa_prim:
  1043.     mov    di,fend            ;make di point to some free memory.
  1044.     add    di,2
  1045.     mov    si,fbgn            ;point si at "sa".
  1046.     mov    si,[si]            ;point si at the first arg.
  1047.     mov    dx,0            ;count the arguments here.
  1048. sa_prim_1:
  1049.     cmp    si,[si]            ;are we pointing at fend?
  1050.     je    sa_prim_2
  1051.     mov    [di],si            ;save a pointer to the argument.
  1052.     add    di,2
  1053.     chk_room
  1054.     mov    si,[si]            ;make it point to next arg.
  1055.     inc    dx
  1056.     jmp    sa_prim_1
  1057. sa_prim_2:
  1058. ;dx=number of arguments.
  1059. ;fend+2->argument pointers.
  1060.  
  1061.     mov    bx,fend            ;make bx point to some free memory.
  1062.     add    bx,2
  1063.  
  1064.     mov    sa_jump,dx
  1065.     dec    dx
  1066.  
  1067. loop1:
  1068.     cmp    sa_jump,1        ;is JUMP > 1?
  1069.     jbe    sa_prim_4        ;no - sort complete
  1070.     shr    sa_jump,1        ;JUMP = JUMP DIV 2
  1071.  
  1072. loop2:
  1073.     mov    bp,1            ;set DONE = TRUE
  1074.     mov    ax,dx            ;get N
  1075.     sub    ax,sa_jump        ;compute N - JUMP
  1076.     mov    sa_n_jump,ax        ;store N - JUMP
  1077.     mov    cx,0
  1078.                     ;for J = 1 to N - JUMP DO
  1079. loop3:
  1080.     mov    si,bx
  1081.     add    si,cx            ;make si -> a[J]
  1082.     add    si,cx
  1083.     mov    di,si
  1084.     add    di,sa_jump        ;offset I by JUMP
  1085.     add    di,sa_jump
  1086.  
  1087.  
  1088.     push    cx
  1089.  
  1090.     push    si
  1091.     push    di
  1092.  
  1093.     mov    si,[si]            ;get the two arguments under consideration.
  1094.     mov    di,[di]
  1095.  
  1096.     mov    ax,[si]            ;compute length of this arg.
  1097.     sub    ax,si
  1098.     sub    ax,mark_overhead
  1099.     add    si,mark_overhead-1    ;make si=> text of argument.
  1100.  
  1101.     mov    cx,[di]            ;compute length of this arg.
  1102.     sub    cx,di
  1103.     sub    cx,mark_overhead
  1104.     add    di,mark_overhead-1    ;make si=> text of argument.
  1105.  
  1106.     cmp    ax,cx            ;if the first string is shorter,
  1107.     jb    sa_prim_8        ;  return if if they're equal.
  1108.                     ;second string is smaller.
  1109.     push    cx
  1110.     repe    cmpsb            ;compare the two strings
  1111.     pop    cx
  1112.     pop    di
  1113.     pop    si
  1114.     jb    sa_prim_5        ;go if they're in order already.
  1115.     ja    sa_prim_6        ;if they're not in order, swap them.
  1116.     cmp    ax,cx            ;were the strings equal?
  1117.     je    sa_prim_5        ;yes - don't swap them.
  1118.     jmp    short sa_prim_6
  1119.  
  1120. sa_prim_8:
  1121.     xchg    cx,ax            ;first string is smaller.
  1122.     repe    cmpsb            ;compare the two strings
  1123.     pop    di
  1124.     pop    si
  1125.     jbe    sa_prim_5        ;go if they're in order already.
  1126.  
  1127. sa_prim_6:
  1128.     mov    ax,[si]            ;swap them.
  1129.     xchg    ax,[di]
  1130.     mov    [si],ax
  1131.     mov    bp,0            ;set DONE = FALSE
  1132. sa_prim_5:
  1133.     pop    cx            ;get the counter back.
  1134.     inc    cx            ;bump the counter
  1135.     cmp    cx,sa_n_jump        ;is cx = N - JUMP?
  1136.     jbe    loop3            ;if cycle not complete, go again
  1137.     cmp    bp,0            ;is DONE = FALSE
  1138.     je    loop2            ;no, another cycle
  1139.     jmp    loop1            ;keep going until sort is complete
  1140.  
  1141. sa_prim_4:
  1142.     inc    dx            ;because we 'dec'ed it before.
  1143.     mov    bx,fend            ;make bx point to some free memory.
  1144.     add    bx,2
  1145.     mov    di,bx            ;compute the end of the table.
  1146.     add    di,dx
  1147.     add    di,dx
  1148.     push    di
  1149. sa_prim_7:
  1150.     mov    si,[bx]
  1151.     add    bx,2
  1152.     mov    cx,[si]            ;compute length of this arg.
  1153.     sub    cx,si
  1154.     sub    cx,mark_overhead
  1155.     add    si,mark_overhead-1    ;make si=> text of argument.
  1156.     inc    cx            ;include space for the comma.
  1157.     chk_room_cnt
  1158.     dec    cx
  1159.     movmem
  1160.     mov    al,','            ;comma terminate the strings.
  1161.     stosb
  1162.  
  1163.     dec    dx            ;done with all of them?
  1164.     jne    sa_prim_7        ;no - do another.
  1165.  
  1166.     jmp    return_tos
  1167.  
  1168.  
  1169. bl_prim:
  1170.     call    get_decimal_arg1
  1171.     push    ax
  1172.     mov    cx,2
  1173.     call    get_decimal_arg
  1174.     mov    cx,ax
  1175.     pop    bx
  1176.     or    bx,bx            ;Do they want the default?
  1177.     jne    bl_prim_1        ;no.
  1178.     mov    bx,bell_pitch        ;yes.
  1179. bl_prim_1:
  1180.     call    ring_the_bell
  1181.     jmp    return_null
  1182.  
  1183.  
  1184. ;push/pop marks
  1185. pm_prim:
  1186.     call    get_decimal_arg1
  1187.     call    stack_marks
  1188.     jc    pm_prim_1
  1189.     jmp    return_null
  1190. pm_prim_1:
  1191.     mov    cx,2
  1192.     jmp    return_arg_active
  1193.  
  1194.  
  1195. ;set mark (to point)
  1196. sm_prim:
  1197.     mov    cx,2
  1198.     call    getarg_mark
  1199.     mov    al,'.'        ;if 2nd is missing, use '.'
  1200.     jcxz    sm_prim_1
  1201.     lodsb
  1202. sm_prim_1:
  1203.     mov    ah,al        ;get source mark
  1204.     push    ax        ;save source mark
  1205.     call    getarg_mark1
  1206.     pop    bx        ;pushed as ax
  1207.     mov    ah,bl        ;get dest mark
  1208.     call    set_mark
  1209.     jmp    return_null
  1210.  
  1211.  
  1212. ;set point (to marks)
  1213. sp_prim:
  1214.     mov    cx,1
  1215.     call    getarg
  1216.     jcxz    sp_prim_1
  1217. sp_prim_2:
  1218.     lodsb
  1219.     push    si
  1220.     push    cx
  1221.     call    goto_mark
  1222.     pop    cx
  1223.     pop    si
  1224.     loop    sp_prim_2
  1225. sp_prim_1:
  1226.     jmp    return_null
  1227.  
  1228.  
  1229. ;delete to mark
  1230. dm_prim:
  1231.     call    write_protect
  1232.     call    getarg1
  1233.     jcxz    dm_prim_1
  1234. dm_prim_2:
  1235.     lodsb
  1236.     push    si
  1237.     push    cx
  1238.     call    del_to_mark
  1239.     pop    cx
  1240.     pop    si
  1241.     loop    dm_prim_2
  1242. dm_prim_1:
  1243.     jmp    return_null
  1244.  
  1245.  
  1246. ;read to mark
  1247. rm_prim:
  1248.     call    getarg_mark1    ;get mark number to read from.
  1249.     call    read_mark    ;returns es:si, cx describing string.
  1250.     assume    ds:nothing
  1251.     di_points_fbgn
  1252. ;    chk_room_cnt
  1253.     mov    ax,es
  1254.     call    buffer_free    ;make sure that there's that much room.
  1255.     jc    rm_prim_1    ;if cy, there must be no room.
  1256.     movmem            ;move the string.
  1257.     push    es        ;restore our ds.
  1258.     pop    ds
  1259.     jmp    return_tos
  1260. rm_prim_1:
  1261.     add    sp,2        ;conserve the stack.
  1262.     push    es        ;restore our ds.
  1263.     pop    ds
  1264.     assume    ds:data
  1265.     mov    cx,2
  1266.     jmp    return_arg_active
  1267.  
  1268.  
  1269. ;translate characters.
  1270. tr_prim:
  1271.     call    write_protect
  1272.     mov    cx,2        ;translate according to arg 2.
  1273.     call    getarg
  1274.     push    si
  1275.     push    cx
  1276.     call    getarg_mark1    ;get mark number to read from.
  1277.     pop    dx
  1278.     pop    bx
  1279.     call    xlat_to_mark
  1280.     jmp    return_null
  1281.  
  1282.  
  1283. ;count to mark
  1284. rc_prim:
  1285.     call    getarg_mark1    ;get mark number to read from.
  1286.     call    read_mark    ;returns ds:si, cx describing string.
  1287.     push    es        ;restore our ds.
  1288.     pop    ds
  1289.     mov    ax,cx
  1290.     di_points_fbgn
  1291.     jmp    return_number
  1292.  
  1293.  
  1294. ;spell check
  1295. sc_prim:
  1296.     push    ds
  1297.     xor    ax,ax
  1298.     mov    ds,ax
  1299.     lds    si,ds:[4*82h]        ;get the speller's interrupt.
  1300.     sub    si,speller_txt_len+2    ;backup past the string and version.
  1301.     mov    di,offset speller_txt
  1302.     mov    cx,speller_txt_len    ;see if the speller is installed.
  1303.     repe    cmpsb
  1304.     pop    ds
  1305.  
  1306.     mov    ax,-1            ;if no speller, return -1.
  1307.     jne    sc_prim_1        ;no speller.
  1308.  
  1309.     call    getarg1_filename
  1310.     push    si
  1311.     mov    cx,2
  1312.     call    get_decimal_arg
  1313.     mov    ah,al
  1314.     pop    si            ;get the pointer to the word.
  1315.     int    82h
  1316. sc_prim_1:
  1317.     di_points_fbgn
  1318.     jmp    return_number
  1319.  
  1320.  
  1321. ;mark before point #(mb,mark,before,after)
  1322. mb_prim:
  1323.     call    getarg_mark1
  1324.     call    read_mark
  1325.     push    es        ;restore our ds.
  1326.     pop    ds
  1327.     jc    mb_prim_1    ;go if point is before mark
  1328.     mov    cx,2
  1329.     jmp    return_arg
  1330. mb_prim_1:
  1331.     mov    cx,3
  1332.     jmp    return_arg
  1333.  
  1334.  
  1335.  
  1336. ;look pattern.  return arg 2 if bad pattern.
  1337. lp_prim:
  1338.     mov    cx,3            ;see if we should be regular or not.
  1339.     call    getarg
  1340.     mov    dx,cx            ;remember it.
  1341.     mov    cx,4            ;see if we should fold case or not.
  1342.     call    getarg
  1343.     mov    di,cx            ;remember it.
  1344.     call    getarg1
  1345.     call    set_pattern
  1346.     jc    lp_prim_1
  1347.     jmp    return_null
  1348. lp_prim_1:
  1349.     mov    cx,2
  1350.     jmp    return_arg_active
  1351.  
  1352.  
  1353. ;look for a string.  return arg 5 if found, arg 6 if not.
  1354. lt_prim:
  1355.     call    getarg_mark1
  1356.     push    ax
  1357.     mov    cx,2
  1358.     call    getarg_mark
  1359.     push    ax
  1360.     mov    cx,3
  1361.     call    getarg_mark
  1362.     push    ax
  1363.     mov    cx,4
  1364.     call    getarg_mark
  1365.     mov    dl,al        ;set arg 4 (last)
  1366.     pop    ax        ;restore arg 3 (first)
  1367.     mov    dh,al
  1368.     pop    cx        ;restore arg 2 (end) pushed as ax.
  1369.     pop    ax        ;restore arg 1 (start)
  1370.     mov    ch,al
  1371.     call    search
  1372.     mov    cx,5        ;if we found it, return arg 5.
  1373.     jnc    lt_prim_1
  1374.     mov    cx,6        ;else return arg 6.
  1375. lt_prim_1:
  1376.     jmp    return_arg
  1377.  
  1378.  
  1379. ;find the first and next occurrences of a file.
  1380. ff_prim:
  1381.     mov    dx,offset filename2
  1382.     mov    ah,1ah
  1383.     int    21h
  1384.     call    getarg1_filename
  1385.     mov    dx,si            ;remember the filename for find_first.
  1386.  
  1387.     di_points_fend
  1388.     mov    ax,[si]
  1389.     cmp    ah,':'            ;does this filename have a drive?
  1390.     jne    ff_prim_9        ;no.
  1391.     mov    ax,[si+2]        ;yes - skip it.
  1392. ff_prim_9:
  1393.     cmp    ax,'/'            ;are they referring to root?
  1394.     je    ff_prim_a
  1395.     cmp    ax,'\'
  1396.     jne    ff_prim_b
  1397. ff_prim_a:
  1398.     mov    cx,5
  1399.     chk_room_cnt
  1400. ff_prim_8:
  1401.     lodsb
  1402.     cmp    al,'/'
  1403.     jne    ff_prim_c
  1404.     mov    al,'\'
  1405. ff_prim_c:
  1406.     stosb
  1407.     or    al,al
  1408.     jne    ff_prim_8
  1409.     dec    di
  1410.  
  1411.     mov    cx,2            ;copy the separator argument.
  1412.     call    getarg
  1413.     chk_room_cnt
  1414.     rep    movsb
  1415.  
  1416.     jmp    return_tos
  1417.  
  1418. ff_prim_b:
  1419.     mov    ah,4eh            ;find first matching file
  1420.     mov    cx,12h            ;find subdirs and hiddens, too.
  1421. ff_prim_1:
  1422.     int    21h            ;find first or find next.
  1423.     jnc    ff_prim_2        ;more files...
  1424.     jmp    return_tos
  1425. ff_prim_2:
  1426.  
  1427.     mov    si,offset filename2.find_buf_name
  1428.     mov    ah,0
  1429. ff_prim_3:
  1430.     lodsb
  1431.     or    al,al
  1432.     je    ff_prim_4
  1433.     cmp    al,'.'            ;remember if we got a '.'.
  1434.     jne    ff_prim_6
  1435.     inc    ah
  1436. ff_prim_6:
  1437.   if 0
  1438.     cmp    si,offset filename2.find_buf_name+1    ;first character?
  1439.     jne    ff_prim_e        ;no, always lowercase it.
  1440.     test    filename2.find_buf_attr,10h    ;is this a subdir?
  1441.     jne    ff_prim_d        ;yes, leave uppercase.
  1442. ff_prim_e:
  1443.   endif
  1444.     call    to_lower
  1445. ff_prim_d:
  1446.     chk_room
  1447.     stosb
  1448.     jmp    ff_prim_3
  1449. ff_prim_4:
  1450.  
  1451.     test    filename2.find_buf_attr,10h    ;is this a subdir?
  1452.     je    ff_prim_5        ;no.
  1453.     mov    al,'\'            ;yes- store a trailing backslash.
  1454.     chk_room
  1455.     stosb
  1456.     jmp    short ff_prim_7        ;don't consider storing '.'.
  1457. ff_prim_5:
  1458.     or    ah,ah            ;did we find a '.'?
  1459.     jne    ff_prim_7
  1460.     mov    al,'.'            ;no - store a trailing '.'.
  1461.     stosb
  1462. ff_prim_7:
  1463.  
  1464.     mov    cx,2            ;copy the separator argument.
  1465.     call    getarg
  1466.     chk_room_cnt
  1467.     rep    movsb
  1468.  
  1469.     mov    ah,4fh            ;find next.
  1470.     jmp    ff_prim_1
  1471.  
  1472.  
  1473. to_lower:
  1474.     cmp    al,'A'            ;uppercase?
  1475.     jb    to_lower_1
  1476.     cmp    al,'Z'
  1477.     ja    to_lower_1
  1478.     add    al,'a'-'A'        ;use uppercase.
  1479. to_lower_1:
  1480.     ret
  1481.  
  1482.  
  1483. ;rename a file.
  1484. rn_prim:
  1485.     call    getarg1_filename
  1486.     mov    cx,2
  1487.     call    getarg
  1488.     mov    di,offset filename2
  1489.     rep    movsb
  1490.     xor    al,al
  1491.     stosb
  1492.     mov    dx,offset filename
  1493.     mov    di,offset filename2
  1494.     mov    ah,56h            ;rename file
  1495.     int    21h
  1496.     jnc    rn_prim_1
  1497.     mov    si,offset rename_error
  1498.     mov    cx,rename_error_len
  1499.     jmp    return_sicx
  1500. rn_prim_1:
  1501.     jmp    return_null
  1502.  
  1503.  
  1504. ;delete a file.
  1505. de_prim:
  1506.     call    getarg1_filename
  1507.     mov    dx,si
  1508.     mov    ah,41h            ;delete file
  1509.     int    21h
  1510.     jnc    de_prim_1
  1511.     mov    al,2
  1512.     mov    bx,offset read_errors
  1513.     jmp    return_string
  1514. de_prim_1:
  1515.     jmp    return_null
  1516.  
  1517.  
  1518. ;read a file
  1519. rf_prim:
  1520.     call    write_protect
  1521.     call    getarg1_filename
  1522.     call    read_file
  1523.     mov    bx,offset read_errors
  1524.     jmp    return_string
  1525.  
  1526.  
  1527. ;write a file.
  1528. wf_prim:
  1529.     call    getarg1_filename
  1530.     push    si            ;preserve the pointer to the filename.
  1531.     mov    cx,2
  1532.     call    getarg_mark
  1533.     pop    si
  1534.     call    write_file
  1535.     mov    bx,offset write_errors
  1536.     jmp    return_string
  1537.  
  1538.  
  1539. ;allocate a buffer
  1540. ba_prim:
  1541.     call    get_decimal_arg1
  1542.     push    ax
  1543.     mov    cx,2
  1544.     call    getarg
  1545.     mov    ax,cx
  1546.     pop    cx            ;pushed as ax.
  1547.     call    buffer_allocate
  1548.     di_points_fbgn
  1549.     jmp    return_number
  1550.  
  1551.  
  1552. ;insert from a buffer
  1553. ;#(bi,buffer number,mark,yes,no)
  1554. bi_prim:
  1555.     call    write_protect
  1556.     call    get_decimal_arg1    ;get the buffer number.
  1557.     push    ax
  1558.     mov    cx,2            ;get the mark.
  1559.     call    getarg_mark
  1560.     pop    cx
  1561.     call    buffer_insert
  1562.     jc    bi_prim_1        ;go if we can't insert it.
  1563.     mov    cx,3
  1564.     jmp    return_arg
  1565. bi_prim_1:
  1566.     mov    cx,4
  1567.     jmp    return_arg
  1568.  
  1569.  
  1570. ao_prim:
  1571.     call    getarg1        ;get the first argument
  1572.     mov    dx,cx        ;save size of first argument
  1573.     mov    di,si        ;save pointer to first argument
  1574.     mov    cx,2        ;get second argument
  1575.     call    getarg
  1576.     cmp    cx,dx        ;second shorter than first?
  1577.     jb    ao_prim_2    ;yes - use second's length.
  1578.     mov    cx,dx        ;no - use first's length.
  1579.     repe    cmpsb        ;strings alphabetically ordered?
  1580.     jb    ao_prim_4    ;no, return 4th.
  1581.     jmp    short ao_prim_3
  1582. ao_prim_2:
  1583.     repe    cmpsb        ;strings alphabetically ordered?
  1584.     jbe    ao_prim_4    ;no, return 4th.
  1585. ao_prim_3:
  1586.     mov    cx,3
  1587.     jmp    return_arg
  1588. ao_prim_4:
  1589.     mov    cx,4
  1590.     jmp    return_arg
  1591.  
  1592.  
  1593. it_prim:
  1594. ;check for key, timed.
  1595.     call    get_decimal_arg1
  1596.     mov    bp,ax            ;save the wait time.
  1597.     or    ax,ax            ;are they really waiting for a char?
  1598.     je    it_prim_0        ;go if not.
  1599.     call    auto_save
  1600. it_prim_0:
  1601.  
  1602.     call    check_for_key        ;character waiting?
  1603.     jne    it_prim_1        ;yes - don't turn the pick on.
  1604.     call    pick_on
  1605.     call    input_timed
  1606.     push    ax            ;preserve the key value.
  1607.     call    pick_off
  1608.     pop    ax
  1609.     jmp    short it_prim_2
  1610. it_prim_1:
  1611.     call    input_timed
  1612. it_prim_2:
  1613.     call    decode_key        ;no - change the key into a string.
  1614.     di_points_fbgn
  1615. it_prim_3:
  1616.     lodsb
  1617.     or    al,al
  1618.     je    it_prim_4
  1619.     chk_room
  1620.     stosb
  1621.     jmp    it_prim_3
  1622. it_prim_4:
  1623.     jmp    return_tos
  1624.  
  1625.  
  1626. input_timed:
  1627.     xor    ax,ax            ;check the mouse buffer first.
  1628.     xchg    ax,mouse_buffer
  1629.     or    ax,ax
  1630.     jne    input_timed_5        ;got one - see if we should restuff it.
  1631.  
  1632.     xor    si,si            ;si is the elapsed time.
  1633.     mov    ah,2ch            ;get the current hundreths.
  1634.     int    21h
  1635.     mov    bl,dl
  1636. input_timed_1:
  1637.     call    check_for_key        ;character waiting?
  1638.     jne    input_timed_2        ;yes - return it.
  1639.     call    check_pick        ;pick waiting?
  1640.     jne    input_timed_5        ;yes - return it.
  1641.     call    give_up_slice
  1642.     mov    ah,2ch            ;gtime
  1643.     int    21h
  1644.     mov    al,dl            ;subtract the new time from the old.
  1645.     sub    al,bl
  1646.     mov    bl,dl            ;update the time in bl.
  1647.     cbw
  1648.     jns    input_timed_4        ;go if it's positive.
  1649.     add    ax,100            ;make it positive.
  1650. input_timed_4:
  1651.     add    si,ax            ;add in to the current time.
  1652.     cmp    si,bp            ;time to timeout yet?
  1653.     jb    input_timed_1        ;no.
  1654.     mov    ax,255            ;yes - timeout.
  1655.     jmp    short input_timed_3
  1656. input_timed_5:
  1657.     or    bp,bp            ;original wait time.
  1658.     jnz    input_timed_3        ;if non zero wait, we're inputting it.
  1659.     mov    mouse_buffer,ax        ;store the mouse button in a buffer.
  1660.     jmp    short input_timed_3
  1661. input_timed_2:
  1662.     or    bp,bp            ;original wait time.
  1663.     jz    input_timed_3        ;if zero wait, we're just checking.
  1664.     call    get_key_value
  1665. input_timed_3:
  1666.     ret
  1667.  
  1668.  
  1669. bc_prim:
  1670.     mov    cx,2        ;get 'from' argument.
  1671.     call    getarg
  1672.     mov    dl,'a'        ;default to ASCII
  1673.     jcxz    bc_prim_1
  1674.     mov    dl,[si]        ;get from type.
  1675. bc_prim_1:
  1676.     mov    cx,3        ;get 'to' argument.
  1677.     call    getarg
  1678.     mov    dh,'d'        ;default to decimal
  1679.     jcxz    bc_prim_2
  1680.     mov    dh,[si]
  1681. bc_prim_2:
  1682.     call    getarg1
  1683.     call    bc_prim_base    ;get the source base.
  1684.     or    bx,bx        ;ASCII?
  1685.     jnz    bc_prim_4    ;no.
  1686.     jcxz    bc_prim_6
  1687.     lodsb
  1688.     mov    ah,0
  1689.     jmp    bc_prim_3
  1690. bc_prim_6:
  1691.     mov    ax,-1        ;if ASCII, and null argument, use -1.
  1692.     jmp    bc_prim_3
  1693. bc_prim_4:
  1694.     push    dx        ;preserve dx.
  1695.     call    get_number
  1696.     pop    dx
  1697. bc_prim_3:
  1698. ;we now have the number in ax.
  1699.     mov    dl,dh
  1700.     call    bc_prim_base
  1701.     di_points_fbgn
  1702.     or    bx,bx
  1703.     jnz    bc_prim_5
  1704.     stosb
  1705.     jmp    return_tos
  1706. bc_prim_5:
  1707.     mov    cx,0        ;use only as many digits as are needed.
  1708.     call    put_number
  1709.     jmp    return_tos
  1710.  
  1711.  
  1712. ;private subroutine, used only bc_prim.
  1713. bc_prim_base:
  1714. ;enter with dl=base character.
  1715. ;exit with bx=base if number; bx=0 if ASCII.
  1716.     or    dl,20h        ;convert UPPER case to lower case.
  1717.     cmp    dl,'d'
  1718.     jne    bc_prim_base_1
  1719.     mov    bx,10
  1720.     ret
  1721. bc_prim_base_1:
  1722.     cmp    dl,'o'
  1723.     jne    bc_prim_base_2
  1724.     mov    bx,8
  1725.     ret
  1726. bc_prim_base_2:
  1727.     cmp    dl,'h'
  1728.     jne    bc_prim_base_3
  1729.     mov    bx,16
  1730.     ret
  1731. bc_prim_base_3:
  1732.     cmp    dl,'c'
  1733.     jne    bc_prim_base_4
  1734.     mov    bx,0
  1735.     ret
  1736. bc_prim_base_4:
  1737.     cmp    dl,'a'        ;a alias character.
  1738.     jne    bc_prim_base_5
  1739.     mov    bx,0
  1740.     ret
  1741. bc_prim_base_5:
  1742.     cmp    dl,'b'
  1743.     jne    bc_prim_base_6
  1744.     mov    bx,2
  1745.     ret
  1746. bc_prim_base_6:
  1747.     ret
  1748.  
  1749.  
  1750. getarg_mark1:
  1751.     mov    cx,1
  1752. getarg_mark:
  1753. ;enter with cx=arg number.
  1754. ;exit with al=mark, cx=arg size, si->arg.
  1755.     call    getarg
  1756.     mov    al,0        ;use null if no string specified.
  1757.     jcxz    getarg_mark_1
  1758.     mov    al,[si]        ;get the first character
  1759. getarg_mark_1:
  1760.     ret
  1761.  
  1762.  
  1763.     public    trace_result
  1764. trace_result:
  1765. ;enter with si->, cx=count of returning result of a primitive call.
  1766. ;doesn't modify si or cx.
  1767.     push    bx
  1768.     push    cx
  1769.     push    si
  1770.     mov    bx,trace_handle
  1771.     or    bx,bx
  1772.     js    trace_result_3
  1773.     mov    al,'{'
  1774.     call    printchar
  1775.     jcxz    trace_result_1
  1776. trace_result_2:
  1777.     lodsb
  1778.     call    printchar
  1779.     loop    trace_result_2
  1780. trace_result_1:
  1781.     mov    al,'}'
  1782.     call    printchar
  1783.     mov    al,CR
  1784.     call    printchar
  1785.     mov    al,LF
  1786.     call    printchar
  1787.     mov    ah,7
  1788.     int    21h
  1789. trace_result_3:
  1790.     pop    si
  1791.     pop    cx
  1792.     pop    bx
  1793.     ret
  1794.  
  1795.  
  1796. neutral_marker    equ    3
  1797.  
  1798.     public    trace_invoke
  1799. trace_invoke:
  1800. ;enter with bx->fbgn, al=function type (active or neutral)
  1801.     push    bx
  1802.     push    dx
  1803.     push    di
  1804.     mov    di,bx
  1805.     mov    bx,trace_handle
  1806.     or    bx,bx
  1807.     js    trace_result_3
  1808.     cmp    al,neutral_marker
  1809.     jne    trace_invoke_1
  1810.     mov    al,"#"
  1811.     call    printchar
  1812. trace_invoke_1:
  1813.     mov    al,"#"
  1814.     call    printchar
  1815.     mov    al,"("
  1816.     call    printchar
  1817. trace_invoke_3:
  1818.     mov    si,di
  1819.     mov    di,[di]
  1820.     cmp    si,di        ;at end?
  1821.     je    trace_invoke_2    ;yes.
  1822.     mov    cx,di
  1823.     sub    cx,si
  1824.     sub    cx,mark_overhead    ;remove overhead.
  1825.     add    si,mark_overhead-1        ;skip past overhead.
  1826.     jcxz    trace_invoke_5
  1827. trace_invoke_4:
  1828.     lodsb
  1829.     call    printchar
  1830.     loop    trace_invoke_4
  1831. trace_invoke_5:
  1832.     cmp    di,[di]            ;last argument?
  1833.     je    trace_invoke_3        ;yes - don't print comma.
  1834.     mov    al,","
  1835.     call    printchar
  1836.     jmp    trace_invoke_3
  1837. trace_invoke_2:
  1838.     mov    al,")"
  1839.     call    printchar
  1840.     pop    di
  1841.     pop    dx
  1842.     pop    bx
  1843. trace_invoke_6:
  1844.     ret
  1845.  
  1846.  
  1847. printchar:
  1848.     mov    dl,al
  1849.     mov    ah,6
  1850.     int    21h
  1851.     ret
  1852.  
  1853.  
  1854. redirect:
  1855. ;enter with bx = device to redirect (0..2).
  1856. ;exit with ax = new flag for this device.
  1857.     mov    cx,bx            ;get the filename.
  1858.     add    cx,3
  1859.     call    getarg_filename
  1860.     je    redirect_1        ;no filename - don't redirect.
  1861.  
  1862.     mov    ah,45h            ;make a copy of handle in bx
  1863.     int    21h            ;  into ax.
  1864.  
  1865.     push    ax            ;remember the old handle.
  1866.     mov    ah,3eh            ;close the original handle.
  1867.     int    21h
  1868.     mov    ax,3d00h        ;open for reading.
  1869.     cmp    bx,0            ;redirecting from stdin?
  1870.     je    redirect_2
  1871.     mov    ah,3ch            ;no - we have to create it.
  1872.     xor    cx,cx
  1873. redirect_2:
  1874.     mov    dx,si            ;point to the filename.
  1875.     int    21h            ;either open or create.
  1876.     jc    redirect_3        ;go if we failed to open it.
  1877.     pop    ax            ;get the old handle back.
  1878.     ret
  1879. redirect_3:
  1880.     mov    cx,bx            ;get the original handle (now closed).
  1881.     pop    bx            ;get the copy of the original handle.
  1882.     mov    ah,46h            ;copy the bx handle to cx.
  1883.     int    21h
  1884.     mov    ah,3eh            ;now close the copy.
  1885.     int    21h
  1886. redirect_1:
  1887.     mov    ax,-1            ;say that there is no file open.
  1888.     ret
  1889.  
  1890.  
  1891. unredirect:
  1892. ;enter with bx = stdxxx file number, cx = handle to restore.
  1893.     cmp    cx,-1
  1894.     je    unredirect_1
  1895.  
  1896.     mov    ah,3eh            ;close stdxxx file.
  1897.     int    21h
  1898.  
  1899.     xchg    bx,cx            ;force the original handle back.
  1900.     mov    ah,46h
  1901.     int    21h
  1902.  
  1903.     mov    ah,3eh            ;close the copy.
  1904.     int    21h
  1905. unredirect_1:
  1906.     ret
  1907.  
  1908.  
  1909. ex_prim:
  1910.     mov    bx,0
  1911.     call    redirect
  1912.     mov    ex_stdin,ax
  1913.  
  1914.     mov    bx,1
  1915.     call    redirect
  1916.     mov    ex_stdout,ax
  1917.  
  1918.     mov    cx,4
  1919.     call    getarg            ;get the fourth argument
  1920.     mov    dx,cx            ;save size of fourth argument
  1921.     mov    di,si            ;save pointer to fourth argument
  1922.     mov    cx,5            ;get fifth argument
  1923.     call    getarg
  1924.     jcxz    ex_prim_2        ;if the fifth argument is empty, we're done.
  1925.     cmp    cx,dx            ;lengths equal?
  1926.     jne    ex_prim_2        ;no, separate redirect.
  1927.     repe    cmpsb            ;strings equal?
  1928.     jne    ex_prim_2        ;no, separate redirect.
  1929.  
  1930.     mov    bx,2
  1931.     mov    ah,45h            ;make a copy of handle in bx
  1932.     int    21h            ;  into ax.
  1933.     mov    ex_stderr,ax        ;remember it.
  1934.  
  1935.     mov    ah,3eh            ;close the original handle.
  1936.     int    21h
  1937.     mov    bx,1            ;now dup stdout into stderr.
  1938.     mov    ah,45h            ;make a copy of handle in bx
  1939.     int    21h            ;  into ax.
  1940.     jmp    short ex_prim_3
  1941.  
  1942. ex_prim_2:
  1943.     mov    bx,2
  1944.     call    redirect
  1945.     mov    ex_stderr,ax
  1946. ex_prim_3:
  1947.  
  1948.     push    swap_screen_flag
  1949.     mov    ax,ex_stdout
  1950.     or    ax,ex_stderr
  1951.     cmp    ax,-1            ;are we redirecting both of them?
  1952.     je    ex_prim_1        ;no.
  1953.     mov    swap_screen_flag,0    ;yes - don't swap screens.
  1954. ex_prim_1:
  1955.  
  1956.     call    getarg1_filename
  1957.     push    si
  1958.     mov    cx,2
  1959.     call    getarg
  1960.     pop    di
  1961.     call    execute_program
  1962.     pop    swap_screen_flag
  1963.  
  1964.     di_points_fbgn
  1965.  
  1966.     push    ax
  1967.     mov    bx,0
  1968.     mov    cx,ex_stdin
  1969.     call    unredirect
  1970.  
  1971.     mov    bx,1
  1972.     mov    cx,ex_stdout
  1973.     call    unredirect
  1974.  
  1975.     mov    bx,2
  1976.     mov    cx,ex_stderr
  1977.     call    unredirect
  1978.     pop    ax
  1979.  
  1980.     jmp    return_number
  1981.  
  1982.     extrn    execute_program: near
  1983.  
  1984.     extrn    get_key_value: near
  1985.     extrn    decode_key: near
  1986.     extrn    buffer_insert: near
  1987.  
  1988.     extrn    return_arg: near
  1989.     extrn    return_number: near
  1990.     extrn    return_null: near
  1991.     extrn    return_sicx: near
  1992.     extrn    return_tos: near
  1993.     extrn    return_arg_active: near
  1994.     extrn    return_string: near
  1995.     extrn    make_active: near
  1996.     extrn    getarg1_filename: near
  1997.     extrn    getarg_filename: near
  1998.     extrn    getarg1: near
  1999.     extrn    getarg: near
  2000.     extrn    get_decimal_arg1: near
  2001.     extrn    get_decimal_arg: near
  2002.     extrn    get_decimal: near
  2003.     extrn    get_number: near
  2004.     extrn    put_number: near
  2005.  
  2006. ;the following externs are defined in mintprim.asm
  2007.     extrn    dflt: near
  2008.     extrn    hl_prim: near
  2009.     extrn    eq_prim: near
  2010.     extrn    ne_prim: near
  2011.     extrn    nc_prim: near
  2012.     extrn    db_prim: near
  2013.     extrn    ct_prim: near
  2014.     extrn    st_prim: near
  2015. ;forms
  2016.     extrn    ds_prim: near
  2017.     extrn    mp_prim: near
  2018.     extrn    gs_prim: near
  2019.     extrn    hk_prim: near
  2020.     extrn    go_prim: near
  2021.     extrn    gn_prim: near
  2022.     extrn    rs_prim: near
  2023.     extrn    fm_prim: near
  2024.     extrn    ev_prim: near
  2025.     extrn    ls_prim: near
  2026.     extrn    es_prim: near
  2027.     extrn    sl_prim: near
  2028.     extrn    ll_prim: near
  2029.     extrn    nb_prim: near
  2030.     extrn    si_prim: near
  2031. ;math
  2032.     extrn    ad_prim: near
  2033.     extrn    su_prim: near
  2034.     extrn    ml_prim: near
  2035.     extrn    dv_prim: near
  2036.     extrn    md_prim: near
  2037.     extrn    and_prim: near
  2038.     extrn    or_prim: near
  2039.     extrn    xor_prim: near
  2040.     extrn    gr_prim: near
  2041.  
  2042.     public    ex_prim
  2043.     public    sc_prim
  2044.  
  2045.     public    rd_prim
  2046.     public    it_prim
  2047.  
  2048.     public    sa_prim
  2049.     public    is_prim
  2050.     public    bc_prim
  2051.     public    sv_prim
  2052.     public    lv_prim
  2053.     public    pp_prim
  2054.     public    bl_prim
  2055.     public    sm_prim
  2056.     public    sp_prim
  2057.     public    dm_prim
  2058.     public    rm_prim
  2059.     public    rc_prim
  2060.     public    mb_prim
  2061.     public    lp_prim
  2062.     public    rf_prim
  2063.     public    wf_prim
  2064.     public    an_prim
  2065.     public    ow_prim
  2066.     public    xy_prim
  2067.     public    pm_prim
  2068.     public    ba_prim
  2069.     public    bi_prim
  2070.     public    ff_prim
  2071.     public    rn_prim
  2072.     public    de_prim
  2073.   if timing
  2074.     public    ec_prim
  2075.   endif
  2076.   if test_prims
  2077.     public    ts_prim
  2078.     public    tt_prim
  2079.   endif
  2080.  
  2081.  
  2082. code    ends
  2083.  
  2084. data    segment    byte public
  2085.     public    function_name_table
  2086.     public    function_name_length
  2087.     public    function_address
  2088.  
  2089. function_name_table    label    word
  2090.     db    'rd'
  2091.     db    'it'
  2092.  
  2093.     db    '=='            ;equals
  2094.     db    '!='            ;not equals
  2095.     db    'nc'            ;number of characters
  2096.     db    'ct'            ;convert time
  2097.     db    'a?'            ;alphabetic ordered?
  2098.     db    'sa'            ;sort ascending
  2099. ;forms
  2100.     db    'ds'            ;define string
  2101.     db    'mp'            ;make parameter
  2102.     db    'gs'            ;get string
  2103.     db    'hk'            ;hook string
  2104.     db    'go'            ;get one
  2105.     db    'gn'            ;get n
  2106.     db    'rs'            ;reset string
  2107.     db    'fm'            ;first match
  2108.     db    'ev'            ;read enviornment
  2109.     db    'ls'            ;list strings
  2110.     db    'es'            ;erase string
  2111.     db    'sl'            ;save library
  2112.     db    'll'            ;load library
  2113.     db    'n?'            ;name exists?
  2114.     db    'si'            ;string index
  2115. ;math
  2116.     db    '++'            ;add
  2117.     db    '--'            ;subtract
  2118.     db    '**'            ;multiply
  2119.     db    '//'            ;divide
  2120.     db    '%%'            ;modulus
  2121.     db    '||'            ;or
  2122.     db    '&&'            ;and
  2123.     db    '^^'            ;xor
  2124.     db    'g?'            ;numeric greater
  2125.  
  2126.     db    'is'            ;insert string
  2127.     db    'bc'            ;base conversion
  2128.     db    'sv'            ;set variable
  2129.     db    'lv'            ;load variable
  2130.     db    'pp'            ;pick position
  2131.     db    'bl'            ;bell
  2132.     db    'sm'            ;set mark
  2133.     db    'sp'            ;set point
  2134.     db    'dm'            ;del to mark
  2135.     db    'rm'            ;read to mark
  2136.     db    'rc'            ;read count
  2137.     db    'mb'            ;mark before
  2138.     db    'lp'            ;look pattern
  2139.     db    'l?'            ;look&test
  2140.     db    'rf'            ;read file
  2141.     db    'wf'            ;write file
  2142.     db    'an'            ;announce
  2143.     db    'ow'            ;overwrite
  2144.     db    'xy'            ;gotoxy
  2145.     db    'pm'            ;push/pop mark
  2146.     db    'ba'            ;buffer allocate
  2147.     db    'bi'            ;buffer insert
  2148.     db    'ff'            ;find files
  2149.     db    'rn'            ;rename file
  2150.     db    'de'            ;delete file
  2151.     db    'st'            ;syntax table
  2152.     db    'hl'            ;halt
  2153.     db    'db'            ;debug
  2154.     db    'tr'            ;translate
  2155.     db    'ex'            ;execute
  2156.     db    'sc'            ;spell check
  2157.   if timing
  2158.     db    'ec'
  2159.   endif
  2160.   if test_prims
  2161.     db    'ts'
  2162.     db    'tt'
  2163.   endif
  2164.  
  2165. function_name_length    equ ($-function_name_table)/2
  2166.  
  2167.     dw    dflt
  2168. function_address    label    word
  2169.     dw    rd_prim        ;redisplay
  2170.     dw    it_prim        ;input timed.
  2171.     dw    eq_prim
  2172.     dw    ne_prim
  2173.     dw    nc_prim
  2174.     dw    ct_prim
  2175.     dw    ao_prim
  2176.     dw    sa_prim
  2177. ;forms
  2178.     dw    ds_prim
  2179.     dw    mp_prim
  2180.     dw    gs_prim
  2181.     dw    hk_prim
  2182.     dw    go_prim
  2183.     dw    gn_prim
  2184.     dw    rs_prim
  2185.     dw    fm_prim
  2186.     dw    ev_prim
  2187.     dw    ls_prim
  2188.     dw    es_prim
  2189.     dw    sl_prim
  2190.     dw    ll_prim
  2191.     dw    nb_prim
  2192.     dw    si_prim
  2193. ;math
  2194.     dw    ad_prim
  2195.     dw    su_prim
  2196.     dw    ml_prim
  2197.     dw    dv_prim
  2198.     dw    md_prim
  2199.     dw    or_prim
  2200.     dw    and_prim
  2201.     dw    xor_prim
  2202.     dw    gr_prim
  2203.  
  2204.     dw    is_prim        ;insert string
  2205.     dw    bc_prim        ;base convert
  2206.     dw    sv_prim        ;set variable
  2207.     dw    lv_prim        ;load variable
  2208.     dw    pp_prim        ;pick position
  2209.     dw    bl_prim        ;bell
  2210.     dw    sm_prim        ;set mark
  2211.     dw    sp_prim        ;set point
  2212.     dw    dm_prim        ;delete to mark
  2213.     dw    rm_prim        ;read to mark
  2214.     dw    rc_prim        ;count to mark
  2215.     dw    mb_prim        ;mark before
  2216.     dw    lp_prim        ;look pattern
  2217.     dw    lt_prim        ;look&test
  2218.     dw    rf_prim        ;read file
  2219.     dw    wf_prim        ;write file
  2220.     dw    an_prim        ;announce
  2221.     dw    ow_prim        ;overwrite
  2222.     dw    xy_prim        ;gotoxy
  2223.     dw    pm_prim        ;push/pop mark
  2224.     dw    ba_prim        ;buffer allocate
  2225.     dw    bi_prim        ;buffer insert
  2226.     dw    ff_prim        ;find first/next
  2227.     dw    rn_prim        ;rename file
  2228.     dw    de_prim        ;delete file
  2229.     dw    st_prim        ;set the syntax table.
  2230.     dw    hl_prim
  2231.     dw    db_prim
  2232.     dw    tr_prim
  2233.     dw    ex_prim
  2234.     dw    sc_prim
  2235.   if timing
  2236.     dw    ec_prim
  2237.   endif
  2238.   if test_prims
  2239.     dw    ts_prim        ;test
  2240.     dw    tt_prim        ;test two
  2241.   endif
  2242.  
  2243. data    ends
  2244.  
  2245.  
  2246.     end
  2247.